<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>住宿费用</title>
		<!-- 页面不要格式化阿 -->
		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="住宿费用">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/sorttable.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/studentDormitoryChargeMgrAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/noConflictOfJquery.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/forCSS.js'></script>
		<script type="text/javascript">
		//全局变量
		var totalcount =-1;
		var enrollyear;
		var feesyear;
		var chargestatus;
		var lodgechargetype;
		
		function searchTotalCount(){
		if($('pageTable').style.visibility == 'visible'){
				$('pageTable').style.visibility = 'hidden';
				}
			if($('MyTable').style.visibility == 'visible'){
				$('MyTable').style.visibility = 'hidden';
				}
			if($('fee_info').style.visibility == 'visible'){
				$('fee_info').style.visibility = 'hidden';
				}
		
		 enrollyear = $("enrollyear").options[$("enrollyear").selectedIndex].value;
		 feesyear = $("feesyear").options[$("feesyear").selectedIndex].value;
		 chargestatus =$("chargestatus").options[$("chargestatus").selectedIndex].value;
		 lodgechargetype = $("lodgechargetype").options[$("lodgechargetype").selectedIndex].value;
		/*if(enrollyear==undefined||enrollyear==-1){
		alert("请选择学生年级!");
		return ;
		}*/
		if(feesyear==undefined||feesyear==-1){
		alert("请选择查看的交费学年！");
		return ;
		}
		if(chargestatus==undefined||chargestatus==-1){
		alert("请选择交费状态!");
		return ;
		}
		/*if(lodgechargetype==undefined||lodgechargetype==-1){
		alert("请选择类别!");
		return ;
		}*/
			
		DWRUtil.removeAllRows('ttb', { filter:function(tr) { //清页面
		      return (tr.id != "pattern");
			    }});

		studentDormitoryChargeMgrAction.getStudentLodgeChargeInfoRows(enrollyear,feesyear,chargestatus,lodgechargetype,totalcb);

		}
		
		//条件查询交费信息
		var totalcb	= function onsearchlodgefeesubmit(totalRows){
		totalcount = totalRows; //给总行数赋值
		studentDormitoryChargeMgrAction.searchStudentLodgeChargeInfoPerPage(1,totalcount,enrollyear,feesyear,chargestatus,lodgechargetype,getfeecb);
		}
		
		var getfeecb = function getfee_cb(feeJson){
			if(feeJson==null){
			if($('pageTable').style.visibility == 'visible'){
				$('pageTable').style.visibility = 'hidden';
				}
			if($('MyTable').style.visibility == 'visible'){
				$('MyTable').style.visibility = 'hidden';
				}
			if($('fee_info').style.visibility == 'visible'){
				$('fee_info').style.visibility = 'hidden';
				}
			if($('toexcel').style.visibility == 'visible'){
				$('toexcel').style.visibility = 'hidden';
				}
				alert("查询交费列表为空!");
				return;
			}
			if($('toexcel').style.visibility == 'hidden'){
				$('toexcel').style.visibility = 'visible';
				}
			if($('pageTable').style.visibility == 'hidden'){
				$('pageTable').style.visibility = 'visible';
				}
			if($('MyTable').style.visibility == 'hidden'){
				$('MyTable').style.visibility = 'visible';
				}
			if($('fee_info').style.visibility == 'hidden'){
				$('fee_info').style.visibility = 'visible';
				}
				DWRUtil.removeAllRows('ttb', { filter:function(tr) {
		      return (tr.id != "pattern");
			    }});
			    
			 var id;
			 //alert(feeJson[0]);
			 //1601,0351113,徐佳,900,0(交费的状态 <1--已经缴费，0--未交费>),1(isextension是否延期 1表示正常，0--表示延期)
			 //65,0200004,解永杰,1200,0,1,管理学院,2号楼 1层101a 房间
			 for (var i =0; i < feeJson.length ; i++) {
			  fee = feeJson[i];
			  id = fee[0];
			 dwr.util.cloneNode("pattern", { idSuffix:id });
		    // dwr.util.setValue("tablestudentid"+id, fee[0]);//隐藏项
		     dwr.util.setValue("tablestudentno"+id, fee[1]);
		     dwr.util.setValue("tablestudentname"+id, fee[2]);
		     dwr.util.setValue("tabledormitorychargefees"+id, fee[3]);
		     if(fee[4]=='1'){
		     dwr.util.setValue("tabledormitorychargestatus"+id, '已经交费');
		     }else{
		     dwr.util.setValue("tabledormitorychargestatus"+id, '未交费');
		     }
		     if(fee[5]=='1'){
		     dwr.util.setValue("tabledormitorychargeisextension"+id, '正常住宿');
		     }else{
		     dwr.util.setValue("tabledormitorychargeisextension"+id, '延期住宿');
		     }
		     
		      if(typeof(fee[6])=="object"){
			 dwr.util.setValue("tablestudentcollege"+id, "");  
			 }else{
		 	  dwr.util.setValue("tablestudentcollege"+id, fee[6]);  
			 }
		      if(typeof(fee[7])=="object"){
			 dwr.util.setValue("tabledormitorydisplayname"+id, "");  
			 }else{
		 	  dwr.util.setValue("tabledormitorydisplayname"+id, fee[7]);  
			 }
		     dwr.util.setValue("cbx" + id, fee.studentid);
		 	 $("pattern" + id).style.display= "";
		  	 }
		   	setPageInfo();
		   	tbCSS();
			}
		
		function setPageInfo(){
		$('pageTd').innerHTML = '';
		studentDormitoryChargeMgrAction.getPage({
			callback:function(data){
				page = data;
				//显示 当前页/总页数
				if(page.totalPage != 0){
					var pageSpan = document.createElement('span');
					//pageSpan.innerHTML = page.currentPage + '/' + page.totalPage;
					pageSpan.innerHTML = '共 '+totalcount+' 条 '+'   第 '+page.currentPage+' 页    共'+page.totalPage+' 页 ';
					$('pageTd').appendChild(pageSpan);
					var aFirst = document.createElement('a');
					aFirst.setAttribute('href','javascript:getFirstData()');
					aFirst.innerHTML = '首页';
					$('pageTd').appendChild(aFirst);
					var aPrevious = document.createElement('a');
					aPrevious.setAttribute('href','javascript:getPreviousData()');
					aPrevious.innerHTML = '上一页 ';
					$('pageTd').appendChild(aPrevious);
					var aNext = document.createElement('a');
					aNext.setAttribute('href','javascript:getNextData()');
					aNext.innerHTML = '下一页 ';
					$('pageTd').appendChild(aNext);
					var aLast = document.createElement('a');
					aLast.setAttribute('href','javascript:getLastData()');
					aLast.innerHTML = '尾页';
					$('pageTd').appendChild(aLast);
				}
			}
		});
		$('loading').style.display = 'none';
	}

		function getFirstData(){
			page.currentPage = 1;
			getDataPerPage();
		}
		
		function getPreviousData(){
			if(page.currentPage>1){
			page.currentPage--;
			}
		getDataPerPage();
		}
		
		function getNextData(){
			if(page.currentPage<page.totalPage){
			page.currentPage++;
			}
		getDataPerPage();
		}
		
		function getLastData(){
			page.currentPage = page.totalPage;
			getDataPerPage();
		}
		
		function gotoPage(select){
			page.currentPage = select.options[select.selectedIndex].value;
			getDataPerPage();
		}
		
		function getDataPerPage(){
			$('loading').style.display = 'block';
			studentDormitoryChargeMgrAction.searchStudentLodgeChargeInfoPerPage(page.currentPage,totalcount,enrollyear,feesyear,chargestatus,lodgechargetype,getfeecb);
		}
		
		</script>
	</head>
	<body>
		<div id="page_container">
			<%@   include file="nav.jsp"%>
			<div id="outlier"></div>
			<div align="center">
				<form action="lodgemgr/exportchargefeetoexcel.action" method="post"
					id="formForExportToExcel" onsubmit="return true">
					学生年级：
					<select id="enrollyear" name="enrollyear" style="width: 100px;">
						<option value="-1" selected="selected">
							请选择年级
						</option>
						<option value="2004">
							2004级
						</option>
						<option value="2005">
							2005级
						</option>
						<option value="2006">
							2006级
						</option>
						<option value="2007">
							2007级
						</option>
						<option value="2008">
							2008级
						</option>
						<option value="2009">
							2009级
						</option>
						<option value="2010">
							2010级
						</option>
					</select>
					交费学年：
					<select id="feesyear" name="feesyear" style="width: 100px;">
						<option value="-1" selected="selected">
							请选择年级
						</option>
						<option value="2004">
							2004年
						</option>
						<option value="2005">
							2005年
						</option>
						<option value="2006">
							2006年
						</option>
						<option value="2007">
							2007年
						</option>
						<option value="2008">
							2008年
						</option>
						<option value="2009">
							2009年
						</option>
						<option value="2010">
							2010年
						</option>
					</select>
					<!-- 1--已经缴费，0--未交费 -->
					状态:
					<select id="chargestatus" name="chargestatus" style="width: 100px;">
						<option value="-1">
							交费状态
						</option>
						<option value="1">
							交费
						</option>
						<option value="0">
							未交费
						</option>
					</select>
					<!-- 1--表示正常，0--表示延期 -->
					类别:
					<select id="lodgechargetype" name="lodgechargetype"
						style="width: 100px;">
						<option value="-1">
							交费类别
						</option>
						<option value="1">
							正常住宿
						</option>
						<option value="0">
							延期
						</option>
					</select>
					<div id="outlier"></div>
					<input class="common_button" type="button" value="提交"
						onclick="searchTotalCount();" />
					<input class="common_button" id="toexcel"
						style="visibility: hidden;" type="submit" value="导出Excel" />
					<!--onclick="javascript:ExportToExcel()"-->
				</form>
			</div>
			<div id="fee_info" style="visibility: hidden;">
				<h2>
					交费信息
				</h2>
			</div>
			<!-- 隐藏的项目 -->
			<div id="tablestudentid" style="display: none">
			</div>
			<!-- 隐藏的项目 -->
			<table id="MyTable" class="table_common sortable table_list_style"
				style="visibility: hidden;" rowclass="row_odd,row_even"
				width="600px">
				<thead>
					<tr>
						<!--  
						<th width="0px" height="26">
							<div >
								选择
							</div>
						</th>
						-->
						<th width="12%" height="18">
							<div>
								学生学号
							</div>
						</th>
						<th width="10%" height="18">
							<div>
								学生姓名
							</div>
						</th>
						<th width="10%" height="18">
							<div>
								交费金额
							</div>
						</th>
						<th width="10%" height="18">
							<div>
								交费状态
							</div>
						</th>
						<th width="10%" height="18">
							<div>
								交费类别
							</div>
						</th>
						<th width="19%" height="18">
							<div>
								学院
							</div>
						</th>
						<th height="18">
							<div>
								所在宿舍
							</div>
						</th>
					</tr>
				</thead>
				<tbody id="ttb">
					<tr id="pattern" style="display: none;">
						<!-- 此处不要格式化 -->
						<!-- <td><div ><input type="checkbox" id="cbx" name="cbx" value="checkbox" /></div></td>-->
						<td>
							<div id="tablestudentno"></div>
						</td>
						<td>
							<div id="tablestudentname"></div>
						</td>
						<td>
							<div id="tabledormitorychargefees"></div>
						</td>
						<td>
							<div id="tabledormitorychargestatus"></div>
						</td>
						<td>
							<div id="tabledormitorychargeisextension"></div>
						</td>
						<td>
							<div id="tablestudentcollege"></div>
						</td>
						<td>
							<div id="tabledormitorydisplayname"></div>
						</td>
						<!-- 此处不要格式化 -->
					</tr>
				</tbody>
			</table>
			<table id="pageTable"
				style="visibility: hidden; margin-top: 30px; font: 12px;"
				class="navigator">
				<tr>
					<td id="pageTd">
					</td>
				</tr>
			</table>
			<div id="loading"
				style="display: none; margin-top: 20px; text-align: center; color: red; font: 13px;">
				Loading...
			</div>
		</div>
	</body>
</html>